feat: Add async hook, plugin, and flag tracker#463
Open
jsonbailey wants to merge 1 commit into
Open
Conversation
jsonbailey
force-pushed
the
jb/sdk-2737/async-hooks-plugins-tracker
branch
from
July 21, 2026 20:27
bc1d428 to
f0bd132
Compare
jsonbailey
force-pushed
the
jb/sdk-2737/async-hooks-plugins-tracker
branch
from
July 21, 2026 20:47
f0bd132 to
cc93fc2
Compare
jsonbailey
marked this pull request as ready for review
July 21, 2026 21:19
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cc93fc2. Configure here.
jsonbailey
force-pushed
the
jb/sdk-2737/async-hooks-plugins-tracker
branch
from
July 21, 2026 21:37
cc93fc2 to
9869242
Compare
keelerm84
approved these changes
Jul 22, 2026
| self.__value: Any = None | ||
|
|
||
| @classmethod | ||
| async def create(cls, key: str, context: Context, listener: Callable[[FlagValueChange], None], eval_fn: Callable, scheduler: AsyncCallbackScheduler) -> 'AsyncFlagValueChangeListener': |
Member
There was a problem hiding this comment.
I'm not a fan of having 2 ways to create this (init and create) when the behavior would be different.
I can see why we are doing this though. Maybe we can just add some documentation to the init making it very clear you shouldn't use this method to instantiate the change listener?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Overview
This slice adds the async counterparts of the SDK's hook and plugin extension points, plus the async flag tracker used by the async client:
AsyncHook(ldclient/hook.py) — abstract base for async hooks.before_evaluation/after_evaluationare coroutines awaited by the async client.AsyncPlugin(ldclient/plugin.py) — abstract base for async plugins.register()is a coroutine (allowing async initialization such as connecting to telemetry backends);get_hooks()remains synchronous and returnsAsyncHookinstances.AsyncFlagTrackerImpl/AsyncFlagValueChangeListener(ldclient/impl/async_flag_tracker.py) — the async flag tracker implementation.Unit tests are added in
ldclient/testing/test_async_hooks.pyandldclient/testing/test_async_flag_tracker.py.The async public classes carry the experimental
.. caution::block, matching the rest of the async surface.This PR depends only on already-merged foundation work and can be reviewed independently.
Tracked internally: SDK-2737
Note
Low Risk
Additive experimental async APIs and new implementation files; no changes to sync client evaluation or existing plugin contracts.
Overview
Adds experimental async extension points and flag-change tracking for
AsyncLDClient, paralleling the existing syncHook,Plugin, andFlagTrackerImpl.AsyncHookinhook.pymirrorsHookbut withasyncbefore_evaluation/after_evaluationcoroutines the async client will await.AsyncPlugininplugin.pyadds an asyncregister()forAsyncLDClientand synchronousget_hooks()returningAsyncHookinstances only (withAsyncHookimported alongsideHook).AsyncFlagTrackerImplandAsyncFlagValueChangeListenerimplement async flag-value change listeners: baseline evaluation on subscribe (no initial callback), re-evaluation on matchingFlagChangeevents, deduplication when the value is unchanged, and scheduling viaAsyncCallbackSchedulerso notifications work from worker threads without a running loop.Unit tests cover hook dispatch order (before forward, after reverse), per-hook isolated hook data, and tracker add/remove/thread-notify behavior.
Reviewed by Cursor Bugbot for commit 9869242. Bugbot is set up for automated code reviews on this repo. Configure here.